<?php if(!defined('PHPOK_SET')){die('<h3>Error...</h3>');}?><footer class="foot"><a href="<?php echo $_sys[siteurl];?>">&copy; Powered by <?php echo $_sys[copyright];?></a></footer>
<script src="http://g.tbcdn.cn/kissy/k/1.4.0/seed.js"></script>
<script src="js/mod.jjr.js"></script>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<?php
	include(LIBS.'/WeixinJs/WeixinJs.class.php');  
	$weixinJs = new \WeixinJs("wxa9adc2cde1638e75","ac5418ff04ffcc3e0bb05c38bff32821");
	$signPackage = $weixinJs->GetSignPackage();
	$appId = $signPackage['appId'];
	$timestamp = $signPackage['timestamp'];
	$nonceStr = $signPackage['nonceStr'];
	$signature = $signPackage['signature'];

	$signPackage['sharetitle'] = $_sys['wx_title'];
	$signPackage['slink'] = $_sys['wx_link'];
	$signPackage['sharedesc'] = $_sys['wx_description'];
	$signPackage['sharepic'] = $_sys['siteurl'].$_sys['wx_logo'];

?>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	// 注意：所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。 
	// 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
	// 完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
	wx.config({
		debug: false,
		appId: '<?php echo $signPackage['appId'];?>',
		timestamp: <?php echo $signPackage['timestamp'];?>,
		nonceStr: '<?php echo $signPackage['nonceStr'];?>',
		signature: '<?php echo $signPackage['signature'];?>',
		jsApiList: [
		'checkJsApi',
		'onMenuShareTimeline',
		'onMenuShareAppMessage'
		]
	});
	
	wx.ready(function () {
		// 在这里调用 API
		//监听“分享到朋友圈”按钮点击
		//desc:"<?php echo $signPackage['sharedesc'];?>",
		wx.onMenuShareTimeline({
			title: "<?php echo $signPackage['sharetitle'];?>",
			link:"<?php echo $signPackage['slink'];?>",
			imgUrl: "<?php echo $signPackage['sharepic'];?>",
			trigger: function (res) {
				// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
				1;
			},
			success: function (res) {
				var pars = "";
				var parsprams = "";
				var randomcode = Math.random() * 100000;
				parsprams = pars + "&code=" + randomcode + "&f=updategroup";
				$.ajax({
					url: 'index.php?c=home',
					type: "Get",
					data: parsprams,
					beforeSend: function () { },
					success: function (state) {
						alert(state);
					}
				});		
			},
			cancel: function (res) {
				alert("您取消了分享！");
			}
		});
		//监听“发送给朋友”按钮点击
		wx.onMenuShareAppMessage({
			title: "<?php echo $signPackage['sharetitle'];?>",
			link:"<?php echo $signPackage['slink'];?>",
			desc:"<?php echo $signPackage['sharedesc'];?>",
			imgUrl: "<?php echo $signPackage['sharepic'];?>",
			trigger: function (res) {
				// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
				1;
			},
			success: function (res) {
				var pars = "";
				var parsprams = "";
				var randomcode = Math.random() * 100000;
				parsprams = pars + "&code=" + randomcode + "&f=updategroup";
				$.ajax({
					url: 'index.php?c=home',
					type: "Get",
					data: parsprams,
					beforeSend: function () { },
					success: function (state) {
						alert(state);
						window.reload();
					}
				});		
			},
			cancel: function (res) {
				alert("您取消了分享！");
			}
		});
	});
</script>
<div id="fixed" style="display:none">
    <ul id="fixed-foot">
    <li class="border-left-none"><a href="javascript:history.go(-1);"><span class="fixed-button icon_arr_back"></span></a></li>
    <li class="border-right-none"><a href="<?php echo site_url('home');?>"><span class="fixed-button icon_arr_home"></span></a></li>
    </ul>
</div>
</body>
</html>